Skip to content

check state instead of power state on change offering for ROOT volume#13271

Open
DaanHoogland wants to merge 2 commits into
apache:4.22from
shapeblue:ghi13261-changeOffering
Open

check state instead of power state on change offering for ROOT volume#13271
DaanHoogland wants to merge 2 commits into
apache:4.22from
shapeblue:ghi13261-changeOffering

Conversation

@DaanHoogland
Copy link
Copy Markdown
Contributor

Description

This PR...

Fixes: #13261

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

Copy link
Copy Markdown
Member

@weizhouapache weizhouapache left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code lgtm

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates ROOT volume resize/offering-change validation for VMware to use the VM state (e.g., Stopped) instead of the VM power_state (e.g., PowerOff), addressing cases where VMware power state lags and incorrectly blocks disk offering changes.

Changes:

  • Switch VMware ROOT-volume validation from userVm.getPowerState() to userVm.getState() in resizeVolumeInternal.
  • Apply the same state-based validation in validateVolumeReadyStateAndHypervisorChecks.
  • Update corresponding log/error messages to reference Stopped state.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +2319 to 2324
if (Volume.Type.ROOT.equals(volume.getVolumeType())
&& ! State.Stopped.equals(userVm.getState())
&& HypervisorType.VMware.equals(hypervisorType)) {
logger.error("For ROOT volume resize VM should be in Stopped state.");
throw new InvalidParameterValueException("VM current state is : " + userVm.getState() + ". But VM should be in " + State.Stopped + " state.");
}
logger.error(" For ROOT volume resize VM should be in Power Off state.");
throw new InvalidParameterValueException("VM current state is : " + userVm.getPowerState() + ". But VM should be in " + VirtualMachine.PowerState.PowerOff + " state.");
if (Volume.Type.ROOT.equals(volume.getVolumeType())
&& ! State.Stopped.equals(userVm.getState())
&& ! State.Stopped.equals(userVm.getState())
&& HypervisorType.VMware.equals(hypervisorType)) {
logger.error("For ROOT volume resize VM should be in Stopped state.");
throw new InvalidParameterValueException("VM current state is : " + userVm.getState() + ". But VM should be in " + State.Stopped + " state.");
&& !State.Stopped.equals(userVm.getState())
&& hypervisorType == HypervisorType.VMware) {
logger.error("For ROOT volume resize VM should be in Stopped state.");
throw new InvalidParameterValueException("VM current state is : " + userVm.getState() + ". But VM should be in " + State.Stopped + " state.");
@codecov
Copy link
Copy Markdown

codecov Bot commented May 28, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.68%. Comparing base (21b2025) to head (69def68).

Files with missing lines Patch % Lines
...n/java/com/cloud/storage/VolumeApiServiceImpl.java 50.00% 0 Missing and 5 partials ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               4.22   #13271   +/-   ##
=========================================
  Coverage     17.67%   17.68%           
- Complexity    15792    15797    +5     
=========================================
  Files          5922     5922           
  Lines        533165   533169    +4     
  Branches      65208    65212    +4     
=========================================
+ Hits          94242    94291   +49     
+ Misses       428276   428219   -57     
- Partials      10647    10659   +12     
Flag Coverage Δ
uitests 3.69% <ø> (ø)
unittests 18.76% <50.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failed to change offering of ROOT volume on VMware

3 participants